package net.lab1024.sa.admin.module.business.erp.prp.controller;

import net.lab1024.sa.admin.module.business.erp.prp.domain.form.PrpordaAddForm;
import net.lab1024.sa.admin.module.business.erp.prp.domain.form.PrpordaQueryForm;
import net.lab1024.sa.admin.module.business.erp.prp.domain.form.PrpordaUpdateForm;
import net.lab1024.sa.admin.module.business.erp.prp.domain.vo.PrpordaVO;
import net.lab1024.sa.admin.module.business.erp.prp.service.PrpordaService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 生产计划行 Controller
 *
 * @Author AKITA
 * @Date 2025-08-08 15:03:21
 * @Copyright AKITA
 */

@RestController
@Tag(name = "生产计划行")
public class PrpordaController {

    @Resource
    private PrpordaService prpordaService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/prporda/queryPage")
    @SaCheckPermission("prporda:query")
    public ResponseDTO<PageResult<PrpordaVO>> queryPage(@RequestBody @Valid PrpordaQueryForm queryForm) {
        return ResponseDTO.ok(prpordaService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/prporda/add")
    @SaCheckPermission("prporda:add")
    public ResponseDTO<String> add(@RequestBody @Valid PrpordaAddForm addForm) {
        return prpordaService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/prporda/update")
    @SaCheckPermission("prporda:update")
    public ResponseDTO<String> update(@RequestBody @Valid PrpordaUpdateForm updateForm) {
        return prpordaService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/prporda/batchDelete")
    @SaCheckPermission("prporda:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return prpordaService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/prporda/delete/{id}")
    @SaCheckPermission("prporda:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return prpordaService.delete(id);
    }
}
